package com.example.demo5;
/**
 * @author 张成
 * @date 2022/3/22 10:39
 * @version 1.0
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.Date;

@WebServlet(name = "SessionServlet1", value = "/SessionServlet1")
public class SessionServlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        session.setAttribute("time",new Date());
        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/SessionServlet2");
        requestDispatcher.forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
